#include "textscreen.h"
#include <stdint.h>

namespace krnlib {
    uint32_t textscreen::VGA_WIDTH = 80;
    uint32_t textscreen::VGA_HEIGHT = 25;
    void textscreen::putc(char c, uint32_t x, uint32_t y) {
        putc(c, y * VGA_HEIGHT + x);
    }
    void textscreen::putc(char c, uint32_t pos) {
        gmem[2 * pos] = vga_colour;
        gmem[2 * pos + 1] = (uint8_t)c;
    }
    void textscreen::setforeground(enum VGAColour fg) {
        foreground = fg;
        refreshcolour();
    }
    void textscreen::setbackground(enum VGAColour bg) {
        background = bg;
        refreshcolour();
    }
    void textscreen::refreshcolour() {
        vga_colour = foreground | background << 4;
    }
    textscreen::textscreen() {
        gmem = (uint8_t*)0xB8000;
        setforeground(VGA_WHITE);
        setbackground(VGA_BLACK);
        for(int i = 0; i < VGA_HEIGHT * VGA_WIDTH; ++i) {
            putc(' ', i);
        }
        initialized = true;
    }
    int main() {
        return 0;
    }
}
